Code instrumentation is a technique that allows computer software to be monitored at runtime, such as to facilitate debugging efforts. For example, software code may be instrumented by inserting instructions that display debugging messages or that write information related to program behavior to a log file. In this way software developers may learn about the internal behavior of the software they write and identify aberrant behavior.
The main drawback of code instrumentation is that it typically requires a significant amount of resources, both in terms of memory and of processing power. Typically, instrumentation engines insert instructions into the entire code base of a software application, resulting in bloated and sluggish code. Furthermore, instrumentation engines typically employ only rudimentary logic to determine the parts of a software application where instrumentation is both applicable and desirable. For example, instrumentation engines often insert instructions into parts of software code that are unreachable given an input vector that is of interest during debugging, or even parts that are unreachable under any conditions (i.e., dead code). More efficient code instrumentation would therefore be advantageous.